<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>流程节点邮件提醒配置</title>
<script src="${ctx}/static/js/selectWin/userSelector.js" type="text/javascript"></script>
<script type="text/javascript">
	var $grid;
	$(function() {
		$(".selectPerson").click(function() {
			var $input = $("#receiver");
			$.easyui.showGridSelector($.extend(userSelectOpts, {
				onEnter : function(val) {
					$input.val("用户:" + val[0].trueName);
					$input.validatebox("validate");
				}
			}));
		});
		$grid = $("#grid").datagrid($.extend(datagridOption, {
			url : "${ctx}/bpm/confNotice/dataGrid?search_EQ_bpmConfNode.id=${bpmConfNodeId}",
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'bpmConfNode',
				title : '所属流程节点',
				formatter : function(value, row, index) {
					return value ? value.name : "";
				}
			}, {
				field : 'receiverUser',
				title : '提醒人',
				formatter : function(value, row, index) {
					return value ? value.trueName : row.receiver;
				}
			}, {
				field : 'dueDate',
				title : '提醒时间'
			}, {
				field : 'type',
				title : '提醒时机',
				formatter : function(value, row, index) {
					switch (value) {
					case 0:
						return "到达";
					case 1:
						return "完成";
					case 3:
						return "超时";
					}
				}
			}, {
				field : 'bpmMailTemplate',
				title : '邮件模板',
				formatter : function(value, row, index) {
					return value ? value.name : "";
				}
			} ] ]
		}));
		$("#add").click(function() {
			$("#fm").form("clear");
			$("#fm").form("load", {
				"bpmConfNode.id" : $("#bpmConfNodeId").val()
			});
			$("#dlg").dialog("open").dialog("setTitle", "新增");
		});
		$("#delete").click(function() {
			GridDelete("#grid", "${ctx}/bpm/confNotice/delete");
		});
	});
	function fn_save() {
		$("#fm").form("submit", {
			url : "${ctx}/bpm/confNotice/update",
			success : function(data) {
				$grid.datagrid("load");
				$.messager.show({
					msg : data.msg,
					icon : "info",
					position : "bottomRight"
				});
				$("#dlg").dialog('close');
			}
		});
	}
</script>
</head>
<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="easyui-toolbar">
		<input type="hidden" id="bpmConfNodeId" value="${bpmConfNodeId}" />
		<a id="add" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-add'">新增</a>
		<a id="delete" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-busy'">删除</a>
	</div>
	<div id="dlg" class="easyui-dialog" style="width: 560px; height: 240px; padding: 10px 20px"
		data-options="iconCls:'icon-save',resizable:true,modal:true,inline:false, buttons:[
                    { text: '保存', iconCls: 'icon-ok', handler: function () { fn_save(); } },
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
                ],closed:true">
		<form id="fm" method="post">
			<input type="hidden" name="id" />
			<input type="hidden" name="bpmConfNode.id" />
			<fieldset style="border: solid 1px #aaa; padding: 3px;">
				<legend>编辑</legend>
				<table id="tbl">
					<tr>
						<td>类型:</td>
						<td><select class="easyui-combobox" name="type" data-options="required:true" style="width: 150px;">
								<option value="0">到达</option>
								<option value="1">完成</option>
								<option value="2">超时</option>
						</select></td>
					</tr>
					<tr>
						<td>提醒人:</td>
						<td><input id="receiver" name="receiver" class="easyui-validatebox" data-options="required:true"> <a
								class="selectPerson easyui-linkbutton easyui-tooltip" title="选取提醒人" data-options="plain: true, iconCls: 'icon-hamburg-customers'"></a>
							<label style="color: red">也可直接写：任务接收人，流程发起人</label></td>
					</tr>
					<tr>
						<td>提醒时间:</td>
						<td><input name="dueDate" class="easyui-validatebox"></td>
					</tr>
					<tr>
						<td>邮件模板:</td>
						<td><select name="bpmMailTemplate" class="easyui-combobox" style="width: 150px">
								<c:forEach items="${mailTemplateList}" var="ft">
									<option value="${ft.id}">${ft.name}</option>
								</c:forEach>
						</select></td>
					</tr>
				</table>
			</fieldset>
		</form>
	</div>
</body>
</html>
